﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanmia.Core;
using FluentNHibernate.Mapping;

namespace Tanmia.NHibernate.Mapping
{
    public class VoucherMap : ClassMap<Voucher>
    {
        public VoucherMap()
        {
            Table("Voucher");

            Id(x => x.VoucherID).Not.Nullable().GeneratedBy.Identity();

            Map(x => x.CreateDate).Not.Nullable().Not.Update();
            Map(x => x.Notes).Nullable();
            Map(x => x.PaymentID).Nullable();
            Map(x => x.InvoiceID).Nullable();

            HasMany(x => x.Details).KeyColumn("VoucherID").Cascade.SaveUpdate();

            References(x => x.User, "UserID").Not.Nullable();
        }
    }
}
